﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceProcess;
using System.ComponentModel;
using System.Diagnostics;



namespace Monitor
{
    public class Monitor : ServiceBase
    {
        private EventLog eventLog1;
        //win service. run timer on service start and poll
        //http://www.bloomberg.com/markets/currencies/
        //algorithm

        static void Main()
        {
            ServiceBase[] ServicesToRun;
            // Change the following line to match.
            ServicesToRun = new ServiceBase[] { new Monitor() };
            ServiceBase.Run(ServicesToRun);
        }

        private void InitializeComponent()
        {
            this.eventLog1 = new System.Diagnostics.EventLog();
            ((System.ComponentModel.ISupportInitialize)(this.eventLog1)).BeginInit();
            // 
            // Monitor
            // 
            this.ServiceName = "Monitor";
            ((System.ComponentModel.ISupportInitialize)(this.eventLog1)).EndInit();

        }  

        public Monitor()
        {
            InitializeComponent();
            if (!EventLog.SourceExists("MySource")) 
            {         
                EventLog.CreateEventSource("MySource","MyNewLog");
            }
            eventLog1.Source = "MySource";
            eventLog1.Log = "MyNewLog";
        }

        protected void OnStart(String[] args)
        {
            eventLog1.WriteEntry("In OnStart");
        }

        protected override void OnStop()
        {
            eventLog1.WriteEntry("In onStop.");
        }

        protected override void OnContinue()
        {
            eventLog1.WriteEntry("In OnContinue.");
        }




    }
}